
#设置默认用户列表
UserList=[
    {"UserName":"Able","Funds":12345},
    {"UserName":"Baker","Funds":23456},
    {"UserName":"Charlie","Funds":34567},
    {"UserName":"Dog","Funds":45678},
    ]

#显示资金数量的函数
def ShowFunds(User):
    print("可用资金：")
    print("-"*30)
    print(UserList[User]["Funds"])

while True:
    print("="*12,"请插卡：","="*12)
    UserName=input("插入银行卡（请从Able,Baker,Charlie,Dog中选择）：")
    if UserName =="Able":
        User=0
    elif UserName =="Baker":
        User=1
    elif UserName == "Charlie":
        User=2
    elif UserName == "Dog":
        User=3
    else:
        User=4
        print("无法识别银行卡，系统退出")
        break
    print("银行卡已识别，请稍后···")
    while User!=4:
        print("银行卡已识别，请稍后···")
        OrginalMoney=int(UserList[User]["Funds"])
        print("="*12,"ATM机系统工作中","="*12)
        print("{0:1}{1:9}{2:12}".format("","1.查询","2.存款"))
        print("{0:1}{1:9}{2:12}".format("","3.取款","4.退出"))
        print("="*40)
        key=input("请执行操作：")
        if key == "1":
            print("="*12,"查询","="*12)
            ShowFunds(User)
        elif key == "2":
            TheSavedMoney=input("请输入放入的金额：")
            print("处理中···")
            OrginalMoney+=int(TheSavedMoney)
            UserList[User]["Funds"]=str(OrginalMoney)
            ShowFunds(User)
        elif key == "3":
            TheRemovedMoney=input("请输入取出的金额：")
            print("处理中···")
            OrginalMoney-=int(TheRemovedMoney)
            UserList[User]["Funds"]=str(OrginalMoney)
            ShowFunds(User)
        elif key == "4":
            print("="*12,"退出系统","="*14)
            break        
        else:
            print("无效操作！")


